<div id="tb<?php echo $uniqid;?>" style="padding:5px">
	<table cellspacing="0" cellpadding="0">
		<tbody>
		<tr>
			<td><a href="javascript:void(0);" onclick="memberReload();" class="l-btn l-btn-small l-btn-plain"><span
					class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxin"></i><span
					class="l-btn-text">重载</span></span></a></td>
			<td>
				<select id="memberlistKeywordsType" class="forminput inputstyle textbox-text validatebox-text" style="width:80px">
					<option value="id">会员ID</option>
					<option value="nickname">会员昵称</option>
					<option value="phone">手机号</option>
				</select></td>
			<td><input id="memberlistKeywords" style="width:120px" type="text"
					   class="easyui-input textbox"></td>
			<td><a href="javascript:void(0);" onclick="memberlistSearch();" class="l-btn l-btn-small l-btn-plain"><span
					class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span
					class="l-btn-text">查询</span></span></a></td>
		</tr>
		</tbody>
	</table>
</div>
<div class="con"  style="-moz-user-select:none;">
	<table id="memberlist"></table>
</div>
<script>
	var memberlistSearch = function () {
		var height = 540 - 96;
		var width  = 740 - 2;
		$("#memberlist").datagrid({
			width: width,
			height: height,//高度
			singleSelect: true,//如果为true，则只允许选择一行
			striped: true,//是否显示斑马线效果。
			rownumbers: false,//如果为true，则显示一个行号列。
			pagination: true,//是否显示分页
			pageSize: 10,
			pageList: [10, 15, 20, 25],
			method: 'post',
			sortName: 'id',
			sortOrder: 'desc',
			idField: 'id',
			url: '/admin/member/list',
			queryParams: {
				keywordsType: $('#memberlistKeywordsType').val(),
				keywords: $('#memberlistKeywords').val(),
			},
			fitColumns: true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
			nowrap: true,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
			selectOnCheck: false,
			checkOnSelect: true,
			toolbar: '#tb<?php echo $uniqid;?>',
			columns: [[
				{field: 'id', title: 'ID', width: '10%'},
				{
					field: 'avatar', title: '头像', width: '7%', formatter: function (value, rowData, rowIndex) {
						return value ? "<img height='30px' src='" + value + "'>" : '';
					}
				},
				{field: 'nickname', title: '用户', width: '25%'},
				{field: 'phone', title: '手机号', width: '35%'},
				{
					field: 'level_info', title: '身份', width: '8%', formatter(value, rowData) {
						return value ? value.name : '普通会员';
					}
				},
			]],
		});
	};
	memberlistSearch();
	$('#memberlistsubmit').click(function (data) {
		var row = $('#memberlist').datagrid('getSelected');
		if (!row) {
			$.messager.alert('提示', '请先选择老师！', 'warning');
		}else{
			$.messager.progress();
			$.post('/admin/member/changeParent', {id: '<?php echo $id;?>', parent_member_id: row.id}, function (data) {
				$.messager.progress('close');
				if (data.ret === 0) {
					$.messager.show({
						title: '提示',
						msg: data.msg,
						timeout: 3000,
						showType: 'slide'
					});
					memberReload();
					membereditVm.params.parent_member_id = row.id;
					membereditVm.params.parent = row;
					$("#membereditdlg").dialog('close');
				} else {
					$.messager.alert('提示', data.msg, 'warning');
				}
			}, 'json');
		}
	});
</script>
